

function getAllTransactions() {
	  var records = new JSONArray();

	  var cmd = "select t from TransactionEntity t ";
	  
	  var filter = null;
	 
	    EntityManager.find(  
	    cmd,	
	    filter,
	     function(result) {
	      
	      for( var i = 0; i < result.size() ; ++i ) {
	        
	        records.put( JSONObject.wrap(result.get(i)) );
	      }
	      
	    });
	    
	    var result = new JSONObject();
	    
	    result.put( "records", records );
	    

	    return result.toString() ;

}

function getTransactions() {

  var records = new JSONArray();

  var cmd = "select t from TransactionEntity t where t.type=:type and t.subType=:stype and t.longDate<:lday";
  
  var d = new java.util.Date();
  var filter = toMap({ type:'badge', stype:'out', lday:d.time});

  //var cmd = "select t from TransactionEntity t where t.type=:type and t.subType=:stype and id > :lid ";
  //var filter = new JSONObject("{ type:'badge', stype:'out', lid:19}");
  
  //var cmd = "select t from TransactionEntity t order by date";
  //var filter = null;
 
    EntityManager.find(  
    cmd,	
    filter,
     function(result) {
      
      for( var i = 0; i < result.size() ; ++i ) {
        
        records.put( JSONObject.wrap(result.get(i)) );
      }
      
    });
    
    var result = new JSONObject();
    
    result.put( "records", records );
    

    return result.toString() ;

}

